package edu.hcnu.mapper;

import edu.hcnu.entity.Car;
import edu.hcnu.entity.CarRecord;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description:
 * @author: Administrator
 * @time: 2023/4/29 19:21
 */
@Mapper
public interface CarMapper {
    @Insert("insert into t_car(id,startStation,endStation,seat)values (#{id},#{startStation},#{endStation},#{seat})")
    boolean add(Car car);

    @Select({
            "<script>",
            "SELECT * FROM t_car WHERE id IN",
            "<foreach item='item' collection='ids' separator=',' open='(' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"
    })
    List<Car> queryBatchIds(List<String> ids);

    @Delete("delete from t_car where id=#{cid}")
    boolean deleteByCID(String cid);

    @Select("select * from t_car")
    List<Car> getAllCar();

    @Select("select id from t_car where id=#{cid} ;")
    String isExists(String cid);


}
